package com.lovi.product.controller;

import com.lovi.param.ProductSaveParam;
import com.lovi.pojo.Product;
import com.lovi.product.service.ProductService;
import com.lovi.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class AdminProductController {
    @Autowired
    private ProductService productService;

    @PostMapping("/product/admin/count")
    Long adminCount(@RequestBody Integer categoryId){
        return productService.adminCount(categoryId);

    }
    //loviTODO:


    @PostMapping("/product/admin/save")
    R adminProduct(@RequestBody ProductSaveParam productSaveParam){
        return productService.adminProduct(productSaveParam);

    }

    @PostMapping("/product/admin/update")
    R adminUpdate(@RequestBody Product product){
        return productService.adminUpdate(product);
    }

    @PostMapping("/product/admin/remove")
    R adminRemove(@RequestBody Integer productId){
        return productService.deleteProduct(productId);
    }
}
